home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / dflt19 / statbar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-19  |  1.3 KB  |  55 lines

  1. /* ---------------- statbar.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. int StatusBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  6. {
  7.     char *statusbar;
  8.     switch (msg)    {
  9.         case CREATE_WINDOW:
  10.         case MOVE:
  11.             SendMessage(wnd, CAPTURE_CLOCK, 0, 0);
  12.             break;
  13.         case KEYBOARD:
  14.             if ((int)p1 == CTRL_F4)
  15.                 return TRUE;
  16.             break;
  17.         case PAINT:    
  18.             if (!isVisible(wnd))
  19.                 break;
  20.             statusbar = DFcalloc(1, WindowWidth(wnd)+1);
  21.             memset(statusbar, ' ', WindowWidth(wnd));
  22.             *(statusbar+WindowWidth(wnd)) = '\0';
  23.             strncpy(statusbar+1, "F1=Help", 7);
  24.             if (wnd->text)    {
  25.                 int len = min(strlen(wnd->text), WindowWidth(wnd)-17);
  26.                 if (len > 0)    {
  27.                     int off=(WindowWidth(wnd)-len)/2;
  28.                     strncpy(statusbar+off, wnd->text, len);
  29.                 }
  30.             }
  31.             if (wnd->TimePosted)
  32.                 *(statusbar+WindowWidth(wnd)-8) = '\0';
  33.             SetStandardColor(wnd);
  34.             PutWindowLine(wnd, statusbar, 0, 0);
  35.             free(statusbar);
  36.             return TRUE;
  37.         case BORDER:
  38.             return TRUE;
  39.         case CLOCKTICK:
  40.             SetStandardColor(wnd);
  41.             PutWindowLine(wnd, (char *)p1, WindowWidth(wnd)-8, 0);
  42.             wnd->TimePosted = TRUE;
  43.             SendMessage(wnd->PrevClock, msg, p1, p2);
  44.             return TRUE;
  45.         case CLOSE_WINDOW:
  46.             SendMessage(wnd, RELEASE_CLOCK, 0, 0);
  47.             break;
  48.         default:
  49.             break;
  50.     }
  51.     return BaseWndProc(STATUSBAR, wnd, msg, p1, p2);
  52. }
  53.  
  54. 
  55.